<!--
 * @Date: 2023-05-13 15:40:48
 * @LastEditTime: 2023-06-16 15:22:57

 * 介绍:
-->
<script lang="ts" setup>
import { filterObject } from "@@/utils/tools/object";

const RnoticeBarRef = ref();
const props = withDefaults(
  defineProps<{
    /**closeable：可关闭的，link：链接 */
    mode?: "link" | "closeable";
    text?: string;
    color?: string;
    background?: string;
    leftIcon?: string;
    delay?: StrNumber;
    speed?: StrNumber;
    /**是否开启滚动播放，内容长度溢出时默认开启 */
    scrollable?: boolean;
    /**是否开启文本换行，只在禁用滚动时生效 */
    wrapable?: boolean;
  }>(),
  { scrollable: true }
);
const solt = useSlots();
const emit = defineEmits<{
  (e: "replay"): void;
  (e: "close"): void;
}>();
function reset() {
  RnoticeBarRef.value?.reset();
}
defineExpose({ reset });
const $props = computed(() => filterObject(props));
</script>
<template>
  <van-notice-bar
    class="RnoticeBar"
    v-bind="$props"
    ref="RnoticeBarRef"
    @replay="emit('replay')"
    @close="emit('close')"
  >
    <template v-if="solt.default" #default><slot></slot> </template>
    <template v-if="solt['left-icon']" #left-icon><slot></slot> </template>
    <template v-if="solt['right-icon']" #right-icon><slot></slot> </template>
  </van-notice-bar>
</template>
<style lang="scss" scoped></style>
